package weaver.splittable.modal;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * 数据变动信息
 * 从中间表获取数据变动信息
 */
public class DataChangeInfo implements Comparable<DataChangeInfo> {

    private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private Long id;

    private String type; // insert update delete

    private String tableName; // 原表名

    private String dataIdColumn; // 唯一标识列名

    private String dataId; // 数据唯一标识

    private String synced; // 是否已同步 0 未同步 1 已同步

    private String createTime; // 数据插入时间

    private String syncTime; // 同步时间

    public DataChangeInfo() {}

    public DataChangeInfo(Long id, String type, String tableName, String dataIdColumn, String dataId, String synced, String createTime, String syncTime) {
        this.id = id;
        this.type = type;
        this.tableName = tableName;
        this.dataIdColumn = dataIdColumn;
        this.dataId = dataId;
        this.synced = synced;
        this.createTime = createTime;
        this.syncTime = syncTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getDataIdColumn() {
        return dataIdColumn;
    }

    public void setDataIdColumn(String dataIdColumn) {
        this.dataIdColumn = dataIdColumn;
    }

    public String getDataId() {
        return dataId;
    }

    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    public String getSynced() {
        return synced;
    }

    public void setSynced(String synced) {
        this.synced = synced;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getSyncTime() {
        return syncTime;
    }

    public void setSyncTime(String syncTime) {
        this.syncTime = syncTime;
    }

    @Override
    public boolean equals(Object o) {
        return EqualsBuilder.reflectionEquals(this, o);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public int compareTo(DataChangeInfo o) {
        return this.createTime.compareTo(o.createTime);
    }

    public static void main(String[] args) {

    }
}
